local skel = fk.CreateSkill {
  name = "emo__hunying",
}

skel:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) then
      return data.card.trueName == "jink"
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {skill_name = skel.name,
    prompt = "#emo__hunying-draw:::"..player:usedSkillTimes(skel.name, Player.HistoryRound) + 1})
  end,
  on_use = function(self, event, target, player, data)
    target:drawCards(player:usedSkillTimes(skel.name, Player.HistoryRound), skel.name)
  end,
})

skel:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) and data.card.trueName == "slash" then
      return true
    end
  end,
  on_cost = function (self, event, target, player, data)
    if player.room:askToSkillInvoke(player, {skill_name = skel.name,
    prompt = "#emo__hunying-discard:"..data.to.id.."::" ..player:usedSkillTimes(skel.name, Player.HistoryRound)+1}) then
      event:setCostData(self, {tos = {data.to}})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local x = player:usedSkillTimes(skel.name, Player.HistoryRound)
    room:askToDiscard(data.to, {
      max_num = x, min_num = x, skill_name = skel.name, include_equip = true, cancelable = false,
    })
  end,
})

Fk:loadTranslationTable{
  ["emo__hunying"] = "魂萦",
  [":emo__hunying"] = "每当你使用【闪】时，你可以摸X张牌，每当你使用【杀】指定目标后，你可以令其弃置X张牌（X为此技能本轮发动次数）。",
  ["#emo__hunying-draw"] = "魂萦：你可以摸 %arg 张牌",
  ["#emo__hunying-discard"] = "魂萦：你可以令 %src 弃置 %arg 张牌",
}


return skel
